package main

import "net/http"

//type Refer struct {
//	handler http.Handler
//	refer string
//}

//func (r Refer) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
//	if r.refer == request.Referer() {
//		//writer.Write([]byte("you are right!"))
//	} else {
//		writer.WriteHeader(403)
//		//writer.Write([]byte(request.Referer()))
//	}
//}

func main() {
	//referer := &Refer{
	//	handler: http.HandlerFunc(myHandler),
	//	refer: "",
	//}
	http.HandleFunc("/hello", hello)
	http.HandleFunc("/", index)
	http.ListenAndServe(":80", nil)

}

// 自定义响应内容
func myHandler(w http.ResponseWriter, req *http.Request)  {
	w.Write([]byte("this is my handler"))
}

func hello(w http.ResponseWriter, req *http.Request) {
	w.Write([]byte("hello word!!!"))
}

func index(w http.ResponseWriter, req *http.Request)  {
	w.Write([]byte("this is a index!"))
}
